//
//  ProudctCollectionCell.m
//  AFNetworking
//
//  Created by admin on 2020/4/28.
//

#import "ProudctCollectionCell.h"


@implementation ProudctCollectionHeader
-(instancetype)initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]) {
        [self confitUI];
    }
    return self;
}

-(void)confitUI{
    self.backgroundColor = UIColor.whiteColor;
    [self addSubview:self.titleLab];
}
-(UILabel *)titleLab{
    if (!_titleLab) {
        _titleLab = [[UILabel alloc]initWithFrame:CGRectMake(KPAND_DEF, 0, KAutoAcale(300), 44)];
        _titleLab.font = FONT_BSYS14;
        _titleLab.textColor = COLOR_23;
        _titleLab.backgroundColor = UIColor.clearColor;
    }
    return _titleLab;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    
}
@end
@implementation ProudctCollectionCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configUI];
    }
    return self;
}



-(void)configUI{
    [self addSubview:self.downBtn];
    [self addSubview:self.titleLab];
    [self addSubview:self.proImageView];
    [self addSubview:self.storeLab];
    [self addSubview:self.priceLab];
    [self addSubview:self.deleteBtn];
}

-(UIButton *)downBtn{
    if (!_downBtn) {
        _downBtn = [UIButton new];
        [_downBtn setTitleColor:UIColor.ug_random forState:UIControlStateNormal];
        [_downBtn setTitle:@"下架" forState:UIControlStateNormal];
        [_downBtn ug_radius:4];
        [_downBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
        _downBtn.titleLabel.font = FONT_SYS12;
        _downBtn.backgroundColor = [UIColor ug_hexString:@"#FF5027"];
    }
    return _downBtn;
}

-(UIButton *)deleteBtn{
    if (!_deleteBtn) {
        _deleteBtn = [UIButton new];
        [_deleteBtn setTitle:@"删除" forState:UIControlStateNormal];
        [_deleteBtn ug_borderColor:COLOR_99 width:1];
        [_deleteBtn setTitleColor:COLOR_99 forState:UIControlStateNormal];
        _deleteBtn.titleLabel.font = FONT_SYS12;
         [_deleteBtn ug_radius:4];
    }
    return _deleteBtn;
}
-(UIImageView *)proImageView{
    if (!_proImageView) {
        _proImageView = [UIImageView new];
        [_proImageView ug_borderColor:COLOR_EE width:1];
        [_proImageView ug_radius:4];
#ifdef TESTDEBUG
        [_proImageView setImage:[UIImage imageWithIcon:@"fa-github" backgroundColor:[UIColor ug_random] iconColor:[UIColor ug_hexString:@"#FF5027"] andSize:CGSizeMake(KAutoAcale(63), KAutoAcale(63))]];
#endif
    }
    return _proImageView;
}
-(UILabel *)titleLab{
    if (!_titleLab) {
        _titleLab = [UILabel new];
        _titleLab.textColor = COLOR_23;
        _titleLab.font = FONT_SYS15;
        _titleLab.numberOfLines = 2;
#ifdef TESTDEBUG
        _titleLab.text = @"芝芝莓莓桃焦糖啵鲜奶糖 糖啵鲜奶啵鲜奶";
#endif
    }
    return _titleLab;
}
-(UILabel *)storeLab{
    if (!_storeLab) {
        _storeLab = [UILabel new];
        _storeLab.textColor = COLOR_99;
        _storeLab.font = FONT_SYS12;
#ifdef TESTDEBUG
        _storeLab.text = @"库存10";
#endif
    }
    return _storeLab;
}
-(UILabel *)priceLab{
    if (!_priceLab) {
        _priceLab = [UILabel new];
        _priceLab.textColor = [UIColor ug_hexString:@"#FF5027"];
        _priceLab.font = FONT_BSYS12;
#ifdef TESTDEBUG
        _priceLab.text = @"¥32";
#endif
    }
    return _priceLab;
}


-(void)layoutSubviews{
    [super layoutSubviews];
    [_proImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(KPAND_DEF);
        make.centerY.mas_equalTo(self);
        make.size.mas_equalTo(CGSizeMake(KAutoAcale(90), KAutoAcale(90)));
    }];
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.proImageView.mas_right).mas_offset(KAutoAcale(8));
        make.right.mas_equalTo(self.contentView).mas_offset(KAutoAcale(-8));
        make.top.mas_equalTo(self.proImageView);
    }];
    [_storeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.proImageView.mas_right).mas_offset(KAutoAcale(8));
        make.centerY.mas_equalTo(self.proImageView);
    }];
    [_priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.proImageView.mas_right).mas_offset(KAutoAcale(8));
        make.bottom.mas_equalTo(self.proImageView).mas_offset(KAutoAcale(-8));
    }];
    [_downBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.proImageView);
        make.right.mas_equalTo(self).mas_offset(-KPAND_MID);
        make.width.mas_equalTo(KAutoAcale(45));
        make.height.mas_equalTo(KAutoAcale(24));
    }];
    [_deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.proImageView);
        make.right.mas_equalTo(self.downBtn.mas_left).mas_offset(-KPAND_MID);
        make.width.mas_equalTo(KAutoAcale(45));
        make.height.mas_equalTo(KAutoAcale(24));
    }];
    
}

@end
